package com.cszy.yydqbfq.utils

import java.util.Calendar

object TimeUtils {
    /**
    * 判断当前是否在22:00-6:00之间（跨天时段）
    * @return Boolean true表示在夜间时段
    */
    fun isNightTime(): Boolean {
        val calendar = Calendar.getInstance()
        val currentHour = calendar.get(Calendar.HOUR_OF_DAY)
        return currentHour >= 22 || currentHour < 6
    }

    /**
    * 精确到分钟级的跨天判断（例如22:30-6:15）
    */
    fun isNightTimeWithMinutes(): Boolean {
        val now = Calendar.getInstance()
        val currentTimeInMinutes = now.get(Calendar.HOUR_OF_DAY) * 60 + now.get(Calendar.MINUTE)
        val nightStart = 22 * 60  // 22:00
        val nightEnd = 6 * 60     // 6:00
        return currentTimeInMinutes >= nightStart || currentTimeInMinutes < nightEnd
    }
}